﻿<phone:PhoneApplicationPage
    x:Class="Undercover.View.TreasurePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:interactivity ="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:command="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP8"
    xmlns:converter="clr-namespace:Undercover.ViewModel"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d"
    shell:SystemTray.IsVisible="True">
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent" DataContext="{Binding Source={StaticResource Locator}, Path=Treasure}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="游戏词库" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            
            <TextBlock Text="统计数据" Grid.Row="0"/>
            <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
                <TextBlock Text="总数" FontSize="36"/>
                <TextBlock Text="{Binding TotalCount}" FontSize="36"/>
                <TextBlock Text="，已使用" FontSize="36"/>
                <TextBlock Text="{Binding UseCount}" FontSize="36"/>
            </StackPanel>
            <TextBlock Text="词组包" Grid.Row="2"/>
            <ScrollViewer Grid.Row="3">
                <ItemsControl ItemsSource="{Binding WordPackages}">
                    <ItemsControl.Resources>
                        <converter:BooleanToVisibility x:Key="BooleanToVisibilityConverter"/>
                        <converter:NotOperatorOnBoolean x:Key="NotOperatorOnBooleanConverter"/>
                    </ItemsControl.Resources>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" >
                                <CheckBox Content="{Binding DisplayName}" IsChecked="{Binding Selected, Mode=TwoWay}" IsEnabled="{Binding RequiredToPurchase, Converter={StaticResource NotOperatorOnBooleanConverter}}"/>
                                <Button Content="(buy?)" VerticalAlignment="Center" 
                                            Visibility="{Binding RequiredToPurchase, Converter={StaticResource BooleanToVisibilityConverter}}"
                                            BorderThickness="0"
                                            Command="{Binding Treasure.BuyPackageCommand, Source={StaticResource Locator}}"
                                            CommandParameter="{Binding}"
                                            />
                            </StackPanel>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </ScrollViewer>
            <Button Content="清除使用历史" VerticalAlignment="Bottom" Grid.Row="4"
                    Command="{Binding ClearUseHistoryCommand}"/>
        </Grid>
    </Grid>
    <!--
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar Mode="Default">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="清除使用历史"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
    -->
</phone:PhoneApplicationPage>